import json
import socket
import sys
import struct
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "127.0.0.1"
port = 8887
so.connect((host, port))


# class Test:
# class test:
#     def __init__(self, size, type, data):
#         self.size = size
#         self.type = type
#         self.data = data
#
#     def pack(self):
#         return self.pack()

# struct test:

    # def make(self, size, type, data):
    #     return self.test(size, type, data)


a = {'kk': 11, 'ere': 23}
s = json.dumps(a).encode()
qq = struct.pack("I%ds" % (len(s),), len(s), s)
print(qq)
# while True:
#     data = input('>>').strip()
#     if not data:
#         break
#     s.send(qq)
#     msg = s.recv(1024)
#     if not msg:
#         break
#     print(msg.decode('utf-8'))
so.send(qq)
so.close()
